<form class="layui-form add-costCode-form" id="ycaAddFrom">
    <input type="text" name="cmd" autocomplete="off" class="layui-input"  value="new" style="display:none;">
    <input type="text" name="lookvalue_id" autocomplete="off" class="layui-input" style="display:none;">
    <input type="text" name="id" autocomplete="off" class="layui-input" style="display:none;">
    <div class="layui-form-item ">
        <label class="layui-form-label">编码<span>*</span>:</label>
        <div class="layui-input-block">
            <input type="text" placeholder="请输入编码" name="code" lay-verify="required|code" autocomplete="off"
                  class="layui-input" required>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名称<span>*</span>:</label>
        <div class="layui-input-block">
            <input placeholder="请输入名称" type="text" name="name" lay-verify="required" autocomplete="off"
                  class="layui-input" required>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">单位<span>*</span>:</label>
        <div class="layui-input-block">
            <div id="selectunit" class=" selectunit layui-unselect layui-form-select">
                <div class="layui-select-title">
                    <input type="text" name="unit" placeholder="请输入或选择一个单位" lay-verify="required" value="" class="layui-input layui-unselect" autocomplete="off"><i class="layui-edge"></i>
                </div>
                <dl class="layui-anim layui-anim-upbit" style="">
                    <dd lay-value="g" class="">g</dd>
                    <dd lay-value="kg" class="">kg</dd>
                    <dd lay-value="个" class="">个</dd>
                    <dd lay-value="元" class="">元</dd>
                    <dd lay-value="万元" class="">万元</dd>
                    <dd lay-value="mm" class="">mm</dd>
                    <dd lay-value="cm" class="">cm</dd>
                    <dd lay-value="m" class="">m</dd>
                    <dd lay-value="km" class="">km</dd>
                </dl>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">含税单价<span>*</span>:</label>
        <div class="layui-input-block">
            <input placeholder="请输入含税单价" type="number" name="price" lay-verify="decimal" autocomplete="off"
                  class="layui-input" step="1" required>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" >税率<span>*</span>:</label>
        <div class="layui-input-block">
            <input placeholder="请输入税率" type="number" name="rate" lay-verify="decimal" autocomplete="off"
                  class="layui-input" step="0.1" required>
        </div>
    </div>
    <button class="layui-btn ycasubmit dn"  type="submit" lay-submit="" lay-filter="ycasubmit">立即提交</button>
</form>
<script type="text/javascript">
$('.selectunit input').on('click',function(elem){
  if ($('.selectunit').hasClass("layui-form-selected")) {
    $('.selectunit').attr("class","selectunit layui-unselect layui-form-select");
  }else{
    $('.selectunit').attr("class","selectunit layui-unselect layui-form-select layui-form-selected");
  };
});
$(".selectunit .layui-anim>dd").each(function(elem){
    $(this).on('click',function(){
        $(".selectunit input").val($(this).attr("lay-value"));
        $('.selectunit').attr("class","selectunit layui-unselect layui-form-select");
    })
});
</script>